package ATMAgain;


import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MoneySaveFrame extends JFrame {
    private ICodeService service = new CodeServiceImpl();
    private MyJText textMoney = new MyJText("请输入存款金额",50,100,this);
    private String oldMoney;

    public MoneySaveFrame(){
        this.setLayout(null);

        this.init();

        this.setSize(500,300);
        this.setVisible(true);
        this.setDefaultCloseOperation(3);
        this.setLocationRelativeTo(null);
    }

    private void init(){
        MyButton save = new MyButton("存款",350,200,this);
        save.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                moneySave();
            }
        });
    }

    private void moneySave(){
        service.saveMoney(Integer.parseInt(textMoney.getText()));
        MoneySaveFrame.this.dispose();
        new FindFrame();
    }
}
